<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 了解 -->
      <h2 :[abc]="str">动态插槽名</h2>
      <img :[attr]="url" alt="" />
      <button @click="attr = 'src'">btn</button>

      <!-- 插入的内容会在子组件里面的位置会变动 -->
      <child>
        <template #[position]>
          <span>🍎</span>
        </template>
      </child>
    </div>

    <script src="./lib/Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        template: `
          <div><slot name="before"></slot> - child子组件 - <slot name="after"></slot></div>
        `,
      };

      createApp({
        data() {
          return {
            // position: "after",
            position: "before",
            str: "hello",
            abc: "title",
            attr: "data-src",
            url: "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png",
          };
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
